package com.example.newncee.ui.Mine;

import static android.content.Context.MODE_PRIVATE;

import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.lifecycle.ViewModelProvider;

import com.example.newncee.R;
import com.example.newncee.data.UserTAG;

/**
 * @author Sora
 * time: 2022/2/11 23:28
 * description: a fragment display user info
 */
public class MineFragment extends Fragment {
    SharedPreferences sp;

    public View onCreateView(@NonNull LayoutInflater inflater,
                             ViewGroup container, Bundle savedInstanceState) {
        MineViewModel mineViewModel = new ViewModelProvider(this).get(MineViewModel.class);
        View root = inflater.inflate(R.layout.fragment_mine, container, false);
        sp = requireContext().getSharedPreferences("user",MODE_PRIVATE);

        TextView name = root.findViewById(R.id.txt_my_name);
        TextView score=root.findViewById(R.id.txt_my_score);
        TextView province=root.findViewById(R.id.txt_my_province);
        TextView course=root.findViewById(R.id.txt_my_course);
        TextView test=root.findViewById(R.id.txt_my_test);

        name.setText(sp.getString(UserTAG.USERNAME.getTag(), "default"));
        score.setText(sp.getString(UserTAG.SCORE.getTag(), "default"));
        province.setText(sp.getString(UserTAG.PROVINCE.getTag(), "default"));
        course.setText(sp.getString(UserTAG.COURSE.getTag(), "default"));
        test.setText(sp.getString(UserTAG.TEST.getTag(), "未完成"));

        return root;
    }

}